//
//  XMBlackListTableViewCell.m
//  XunMi
//
//  Created by MacBook on 2024/2/29.
//  Copyright © 2024 TieZhu. All rights reserved.
//

#import "XMUserListTableViewCell.h"

@interface XMUserListTableViewCell ()
@property (weak, nonatomic) IBOutlet UIImageView *headImgV;
@property (weak, nonatomic) IBOutlet UILabel *namaLa;
@property (weak, nonatomic) IBOutlet UILabel *descLa;
@property (weak, nonatomic) IBOutlet UIButton *actBtn;
@property (nonatomic, strong) XMUserModel *model;
@property (nonatomic, assign) XMUserListCellType type;
@end

@implementation XMUserListTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    kCornerRadius(_actBtn, 17, 0, UIColor.clearColor);
    kCornerRadius(_headImgV, 24, 0, UIColor.clearColor);
    [_actBtn setImagePosition:(XMImagePositionLeft) spacing:5];
}

- (IBAction)btnAction:(UIButton *)sender {
    if (self.actBtn) {
        self.actBlock(self.model, self.type);
    }
}

- (void)setupCellWithUser:(XMUserModel *)model type:(XMUserListCellType)type {
    self.model = model;
    self.type = type;
    [_headImgV sd_setImageWithURL:kStringToUrl(model.avatar.file_url) placeholderImage:model.isMan ? kManHeadImg : kWomanHeadImg];
    self.namaLa.text = model.showName;
    self.namaLa.textColor = model.showColor;
    self.descLa.text = model.describe;
    
    switch (type) {
        case XMUserListCellBlack: {
            [_actBtn setImage:kGetImage(@"black_rem") forState:UIControlStateNormal];
            [_actBtn setTitle:@"解除" forState:UIControlStateNormal];
            self.descLa.text = kStringFormat(@"%@", model.block_time);
        } break;
            
        case XMUserListCellFollow:
        case XMUserListCellSeeme: {
            [_actBtn setImage:kGetImage(@"home_sl") forState:UIControlStateNormal];
            [_actBtn setTitle:@"私聊" forState:UIControlStateNormal];
        } break;
            
        case XMUserListCellGuard:
        case XMUserListCellIntimate:
        {
            [_actBtn setImage:kGetImage(@"home_sl") forState:UIControlStateNormal];
            [_actBtn setTitle:@"私聊" forState:UIControlStateNormal];
            self.descLa.text = kStringFormat(@"亲密度：%@°", model.intimacy);
            self.descLa.textColor = kAppMainColor;
        } break;
            
        default:
            break;
    }
}

@end
